﻿using HPIT.RentHouse.DTO;
using HPIT.RentHouse.IService;
using HPIT.RentHouse.Service.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HPIT.RentHouse.Service
{
    public class CommunityService : ICommunityService
    {
        public List<CommuityDTO> GetList(long regionId)
        {
            RentHouseEntities db = new RentHouseEntities();
            BaseService<T_Communities> baseService = new BaseService<T_Communities>(db);
            List<CommuityDTO> list = baseService.GetList(a => a.RegionId == regionId).Select(a => new CommuityDTO()
            {
                Id = a.Id,
                Name = a.Name,
                RegionId = a.RegionId,
                Location=a.Location,
                Traffic=a.Traffic,
                BuiltYear=a.BuiltYear.Value

            }).ToList();
            return list;
        }
    }
}
